package com.cyms.modules.card.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import com.cyms.common.annotation.SysLog;
import com.cyms.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cyms.modules.card.entity.EtcEntity;
import com.cyms.modules.card.service.EtcService;
import com.cyms.common.utils.PageUtils;
import com.cyms.common.utils.R;



/**
 * ETC卡信息
 *
 * @author low
 * @email tolower@foxmail.com
 * @date 2018-12-08 14:54:32
 */
@RestController
@RequestMapping("card/etc")
public class EtcController  extends AbstractController {
    @Autowired
    private EtcService etcService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("card:etc:list")
    public R list(@RequestParam Map<String, Object> params){
        params.put("createOrg",getUser().getCompanyId());
        PageUtils page = etcService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("card:etc:info")
    public R info(@PathVariable("id") Long id){
			EtcEntity etc = etcService.selectById(id);

        return R.ok().put("etc", etc);
    }

    /**
     * 保存
     */
    @SysLog("新增ETC卡信息")
    @RequestMapping("/save")
    @RequiresPermissions("card:etc:save")
    public R save(@RequestBody EtcEntity etc){
    	etc.setStatus("1");
			etcService.insert(etc);

        return R.ok();
    }

    /**
     * 修改
     */
    @SysLog("修改ETC卡信息")
    @RequestMapping("/update")
    @RequiresPermissions("card:etc:update")
    public R update(@RequestBody EtcEntity etc){
			etcService.updateById(etc);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("card:etc:delete")
    public R delete(@RequestBody Long[] ids){
			etcService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
